<template>
    <div class="ordering">
        <!-- 面包屑 -->
        <el-breadcrumb :separator-icon="ArrowRight">
            <el-breadcrumb-item :to="{ path: '/' }">管理员</el-breadcrumb-item>
            <el-breadcrumb-item>校外课题实践</el-breadcrumb-item>
            <el-breadcrumb-item>发布历史</el-breadcrumb-item>
        </el-breadcrumb>

        <div>
            <h2>校外实践课题发布历史</h2>
        </div>

        <!-- 所有课程设计任务内容 -->
        <el-table :data="myPublish" height="550" style="width: 100%; margin-top: 10px;">
            <el-table-column prop="startDate" label="开始时间" :formatter="formatDate" min-width="130"/>
            <el-table-column prop="taskName" label="课题名称" min-width="100" />
            <el-table-column prop="memberMax" label="选报人数" min-width="100" />
            <el-table-column prop="adviserName" label="指导教师" min-width="100"/>
            <el-table-column prop="className" label="班级" min-width="100"/>
            <el-table-column prop="topicType" label="课题类型" min-width="100"/>
            <el-table-column prop="topicTeamId" label="队伍编号" min-width="100"/>
            <el-table-column fixed="right" label="课题详情" min-width="100">
                <template #default="scope">
                    <el-popover placement="right" :width="400" trigger="click">
                        <template #reference>
                            <el-button link type="primary" size="small">详情</el-button>
                        </template>
                        <h2 style="text-align: center">{{ scope.row.taskName }}</h2>
                        <div
                            style="background-color: #f5f5f5; margin-top: 5px; border: 1px solid; border-radius: 5px;min-height: 100px;padding: 5px;">
                            <el-text class="mx-1" size="large">{{ scope.row.content }}</el-text>
                        </div>
                        <h4>评分标准</h4>
                        <div
                            style="background-color: #f5f5f5; margin-top: 5px; border: 1px solid; border-radius: 5px;min-height: 50px;padding: 5px;">
                            <el-text class="mx-1" size="large">{{ scope.row.scaleRule }}</el-text>
                        </div>
                    </el-popover>
                    <el-button link type="primary" size="small">删除</el-button>
                </template>
            </el-table-column>
        </el-table>
    </div>
</template>
<script setup>
import { ArrowRight, Calendar, Search, Plus } from '@element-plus/icons-vue'
import { ref, onBeforeMount } from 'vue'
import { useRouter } from 'vue-router'
import requests from '@/api/ajax.js'

const router_useRouter = useRouter()

const teacherId = '1'

onBeforeMount(() => {
    //初始显示老师所有的发布题目
    const asd = requests({ url: "/excel/allouterTaskVo", method: "get", }).then(res => {
        //存储用户信息到浏览器toke

        const abc = res.rdata
        myPublish.value = abc
        console.log(myPublish.value.length)
    })
        .catch(err => {
            console.error(err.data);
            // 登录请求失败后的操作
        });
})
//     const acd = requests({ url: "/course/course", method: "get", }).then(res => {
//         //存储用户信息到浏览器toke
//         const abc = res.rdata
//         courseOptions.value = abc

//     })
//         .catch(err => {
//             console.error(err.data);
//             // 登录请求失败后的操作
//         });

//     //获取班级和课程编号
//     const aad = requests({ url: "/course/class", method: "get", }).then(res => {
//         //存储用户信息到浏览器toke
//         const abc = res.rdata
//         classNum.value = abc
//         // console.log(classNum.value)

//     })
//         .catch(err => {
//             console.error(err.data);
//             // 登录请求失败后的操作
//         });
//     // console.log(myPublish.value)


// })

//接收课题发布的学期
const publishtask = ref([

])

// 题目种类
const classNum = ref([

])

// 课程类型
const courseOptions = ref([
    {
        courseId: '',
        courseName: '',
    },
])


const input1 = ref('')
const myPublish = ref([{
    topicId: '',
    topicTeamId: '',
    topicType: '',
    publishId: '',
    topicDate: '',
    practicalId: '',
    planId:'' ,
    classId: '',
    className: '',
    adviserId: '',
    adviserName: '',
    teachId: '',
    teachName: '',
    practicalType: '',
    onloadDate: '',
    memberMax: '',
    taskName: '',
    content: '',
    scaleRule: '',
    startDate: '',
    endDate: '',
    subtaskId: '',
    subtaskName: '',
    subtaskContent: '',
}])


//时间格式修改为YY-MM
let i = 0

function formatDate(row, column, cellValue, index) {
    let format = 'YYYY-mm-dd'
    let date = new Date(cellValue);
    const dataItem = {
        'Y+': date.getFullYear().toString(),
        'm+': (date.getMonth() + 1).toString(),
        'd+': date.getDate().toString(),
    }
    Object.keys(dataItem).forEach((item) => {
        const ret = new RegExp(`(${item})`).exec(format);
        if (ret) {
            format = format.replace(ret[1], ret[1].length === 1 ? dataItem[item] : dataItem[item].padStart(ret[1].length, '0'));
        }
    });
    /*  dateFilters.value = format */
    //时间选择栏
    /*  let dateFilters = ref([])
     dateFilters = format */
    // for(let i=0 ; i<myPublish.length;i++){
    //   const obj = ref([])
    //   obj.text = 
    /*   myPublish.value.courseDate = ref(format);
      console.log(myPublish.value.courseDate) */
    console.log(format)
    return format
}
function changeDate() {
    for (let i = 0; i < myPublish.value.length; i++) {
        const obj = {}//每次循环创建一个新的对象
        obj.courseDate = myPublish.value[i].courseDate
        publishtask.value.push(obj);
        publishtask.value[i].courseValue = myPublish.value[i].courseDate
    }

}

function toTaskBase() {
    router_useRouter.push({ path: 'taskBase' })
}







</script>
<style>

</style>